package com.itheima.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Stream;

public class StreamDemo06 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1,"a","b","c","d","e","e","e");

        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2,"q","w","e","r","d","f");

        //Stream<T> filter(Predicate predicate)
        list1.stream().filter(s -> !(s.equals("e")))
                .forEach(s -> System.out.print(s+" "));//a b c d

        System.out.println();
        System.out.println("=================");

        //Stream<T> limit(long maxSize)
        list2.stream().limit(4)
                .forEach(s -> System.out.print(s+" "));//q w e r

        System.out.println();
        System.out.println("=================");

        //Stream<T> skip(long n)
        list2.stream().skip(4)
                .forEach(s -> System.out.print(s+" "));//d f

        System.out.println();
        System.out.println("=================");

        //static <T> Stream<T> concat(Stream a, Stream b)
        //Stream<T> distinct()
        Stream.concat(list1.stream(),list2.stream())
                .distinct().forEach(s -> System.out.print(s+" "));
        //a b c d e q w r f
    }
}
